import 'package:flutter/material.dart';
import 'package:flutter_ui/src/pages/tabs/form-page.dart';
import 'package:flutter_ui/src/pages/tabs/home-page.dart';
import 'package:flutter_ui/src/pages/tabs/my-page.dart';

List<String> tabsTitle = <String>[
  "首页",
  "表单",
  "我的"
];

class TabsPage extends StatefulWidget {
  TabsPage({Key key}) : super(key: key);
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> with SingleTickerProviderStateMixin {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentIndex,
        children: <Widget>[
          HomePage(),
          FormPage(),
          MyPage(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: _currentIndex,
        onTap: (index)=> this.setState((){
          _currentIndex = index;
        }),
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(Icons.home), 
            title: Text("首页")
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.mode_edit), 
            title: Text("表单")
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.person), 
            title: Text("我的")
          )
        ],
      ),
    );
  }
}
